texthandle: Mind the invisible area when moving the handle
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 21 May 2014 12:58:50 +0000 (14:58 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Fri, 23 May 2014 17:54:33 +0000 (19:54 +0200)
The handle is still centered horizontally, but the extra vertical
space wasn't taken into account, leading to misplacing the dragging
point (and the handle) during motion events.

gtk/gtktexthandle.c

index 226198732eb4868edfb8517446155cc9671d1bf8..ab0495513f2cedebf06d38507bab9e98a38b6bd3 100644 (file)
@@ -193,14 +193,18 @@ gtk_text_handle_widget_event (GtkWidget     *widget,
            event->motion.state & GDK_BUTTON1_MASK &&
            priv->windows[pos].dragged)
     {
-      gint x, y, width, height;
+      gint x, y, width, height, handle_height;
+      GtkAllocation allocation;
 
-      _gtk_text_handle_get_size (handle, &width, &height);
+      gtk_widget_get_allocation (priv->windows[pos].widget, &allocation);
+      width = allocation.width;
+      height = allocation.height;
+      _gtk_text_handle_get_size (handle, NULL, &handle_height);
       x = event->motion.x - priv->windows[pos].dx + (width / 2);
       y = event->motion.y - priv->windows[pos].dy;
 
       if (pos != GTK_TEXT_HANDLE_POSITION_CURSOR)
-        y += height;
+        y += height - handle_height;
 
       y += priv->windows[pos].pointing_to.height / 2;